#pragma once

#include "obj.h"
#include "Weapon.h"
#include "core/Collision.hpp"

class Shader;
class Weapon;

struct pathHelper {

	pathHelper() : 
		enabled(false)
	{}

	void setDest(const glm::vec2 & _dest ) {
		dest = _dest;
		enabled = true;
	}
	
	glm::vec2 dest;
	bool enabled;
};

/*
	A player owned war gameobject
	Owns a weapon which runs independently with the playerobject simply being the carrier 
	has a method of movement, this could possibly also be made independent of this object 
*/

class PlayerObj : public Obj
{
public:
	enum RenderOptions { RO_NONE = 0, SELECTED = 1<<1  };

    PlayerObj(glm::vec3 pos, Player* owner);
    virtual ~PlayerObj();
    virtual void update(float dt);
    virtual void draw(bool picking);
	void setRenderOptions(int mask) { renderOptions |= mask; }
	void setDest(const glm::vec2& dest) { pather.setDest(dest); }
	glm::vec2 getDest() { return pather.dest; }
	void stopPathing() { pather.enabled = false; }
	
	void removeRenderOption(int mask) { renderOptions &= ~mask; }
	void addForce(const glm::vec2& force);
	virtual CollGeom* getCollGeom();

	virtual void handleColl(Obj* other);
	virtual void handleColl(PlayerObj* other);
	virtual void handleColl(CannonBall* other);

	void attackMe(float damage);

	Player* owner;
	glm::vec4 color;
	float dim;
	glm::vec2 v;
	float m;
	float maxV;
	float accl;
	glm::vec2 f;

private:
    void initGeometry();
    std::vector<PC3DVertex> vertices;
    GLuint vao;
    GLuint vbo;
    Shader* shader;
	pathHelper pather;
	std::vector<Weapon*> weapons;
	CollisionSphere sphereGeom;
	    
	int renderOptions;
	float health;
};